package com.time.client.infra.basic.service.impl;

import com.time.client.infra.basic.entity.PostCategory;
import com.time.client.infra.basic.mapper.PostCategoryDao;
import com.time.client.infra.basic.service.PostCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文章分类关联表(PostCategories)表服务实现类
 *
 * @author HuangQi
 * @since 2025-09-30 16:26:31
 */
@Service("postCategoryService")
public class PostCategoryServiceImpl implements PostCategoryService {

    @Autowired
    private PostCategoryDao postCategoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PostCategory queryById(Long id) {
        return this.postCategoryDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param postCategory 筛选条件
     * @return 查询结果
     */
    @Override
    public List<PostCategory> queryByCondition(PostCategory postCategory) {
        return this.postCategoryDao.queryByCondition(postCategory);
    }

    /**
     * 新增数据
     *
     * @param postCategory 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(PostCategory postCategory) {
        return this.postCategoryDao.insert(postCategory);
    }

    /**
     * 修改数据
     *
     * @param postCategory 实例对象
     * @return 实例对象
     */
    @Override
    public Integer update(PostCategory postCategory) {
        return this.postCategoryDao.update(postCategory);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public Boolean deleteById(Long id) {
        return this.postCategoryDao.deleteById(id) > 0;
    }

    @Override
    public Integer deleteByCategoryId(Long categoryId) {
        return this.postCategoryDao.deleteByCategoryId(categoryId);
    }

    @Override
    public Integer queryPostCountByCategoryId(Long categoryId) {
        return this.postCategoryDao.countPostByCategoryId(categoryId);
    }

    @Override
    public PostCategory queryByPostId(Long postId) {
        return this.postCategoryDao.queryByPostId(postId);
    }

    @Override
    public Integer deleteByPostId(Long postId) {
        return this.postCategoryDao.deleteByPostId(postId);
    }
}
